<?php

$url = "https://www.google.com/calendar/feeds/pcr8410uq18ue1uupa5pl8qd8o%40group.calendar.google.com/public/basic";

function objectsIntoArray($arrObjData, $arrSkipIndices = array())
{
    $arrData = array();
    
    // if input is object, convert into array
    if (is_object($arrObjData)) {
        $arrObjData = get_object_vars($arrObjData);
    }
    
    if (is_array($arrObjData)) {
        foreach ($arrObjData as $index => $value) {
            if (is_object($value) || is_array($value)) {
                $value = objectsIntoArray($value, $arrSkipIndices); // recursive call
            }
            if (in_array($index, $arrSkipIndices)) {
                continue;
            }
            $arrData[$index] = $value;
        }
    }
    return $arrData;
}
?>


<?php

$xmlStr = file_get_contents($url);
$xmlObj = simplexml_load_string($xmlStr);
$arrXml = objectsIntoArray($xmlObj);

$counter = 0;

echo "<script type=\"text/javascript\">\n" .
		"var timeline_data = {\n" . 
				"'dateTimeFormat': 'iso8601',\n" .
				"'wikiURL': \"http://simile.mit.edu/shelf/\",\n".
				"'wikiSection': \"Simile MONKELABS Timeline\",\n" .
				"'events' : [\n";

foreach($arrXml["entry"] as $entry)
{
		$counter++;
	
		if($counter == count($arrXml["entry"]))
		{
			echo
			
					"{'start': '" . $entry["updated"] . "',\n" .
					"'title': '".$entry["title"]."',\n" .
					"'description': '".$entry["title"]."',\n" .
					"'link': 'http://monkelabs.com'\n" .
					"}\n";
					
		}else
		{
			echo
					"{'start': '".$entry["updated"]."',\n" .
					"'title': '".$entry["title"]."',\n" .
					"'description': '".$entry["title"]."',\n" .
					"'link': 'http://monkelabs.com'\n" .
					"},\n";
		}
					
					

	
}

echo "]}\n";
		echo "</script>\n";


?>